<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<style>
.editor table {
	display: inline;
	vertical-align: top;
}

</style>
<div class="r_location">
	<i class="r_txtico"></i> 内容管理&gt; 活动管理 &gt; 修改活动
</div>
<form id="add_form" action="cms/activity/modify"   method="post">
<input type="hidden" id="productIds" name="productIds" value="${data.productIds}">
<input type="hidden"   name="status" value="${data.status}">
<input type="hidden"   name="id" value="${data.id}">
	<ul class="all_list">
		<li>
			<span class="all_title">活动名称：</span>
			<span>
				<input class="ui_input" id="activityName" value="${data.activityName}" validator='{"label":"活动名称"}'  name="activityName" style="width:200px;">
			</span>
		</li>
		<li>
			<span class="all_title">活动编码：</span>
			<span>
				<input class="ui_input" id="activityCode" readonly="readonly" value="${data.activityCode}" validator='{"label":"活动编码","isDigit":true,"minLength":1,"maxLength":2}'  name="activityCode" style="width:100px;">
			    <font color="red">注意:活动编码必须为1到10的数字</font>
			</span>
		</li>
		<li>
			<span class="all_title">有效时间：</span>
				<span>
				<input type="text" class="ui_input Wdate" id="effectTimeBegin" value="${startDateStr}"
				name="startDateStr" validator='{"label":"活动开始时间","required":true}'
				onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'effectTimeEnd\')}'})">
				- <input type="text" class="ui_input Wdate" id="effectTimeEnd"
				name="endDateStr"  value="${endDateStr}" validator='{"label":"活动结束时间","required":true}'
				onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'effectTimeBegin\')}'})">
			</span>
		</li>
		<li>
			<span class="all_title">参与活动奖品：</span>
			<span>
				<input class="ui_input" id="prizeList" value="${prizeNames}" validator='{"label":"参与活动奖品","isOnBlurEnable":false}'  name="prizeList" style="width:300px;" readonly="readonly">
				<span class="all_title"><input type="button" value="选择" id="select_prize" class="btn_blue m-r15"></span>
			</span>
		<li>
		<li class="editor">
			<span class="all_title">活动规则：</span> 
			<span>
				<textarea id="content" name="activityDesc"   class="xheditor {tools:'FontSize,FontColor,Bold,Italic,Underline,Strikethrough,Fullscreen,Align,About',skin:'default',height:'300'}" 
				rows="8" cols="80" style="width:70%">${data.activityDesc}</textarea>
				<span id="contentError"></span>
			</span>
		</li>
		<li>
			<span class="all_title"></span>
			<span> 
				<input type="button" id="query" value="保存" class="btn_blue m-r15 submitBtn">
			</span>
		</li>
	</ul>
</form>
<script type="text/javascript">
	$.datepicker();
	$(function(){
		$('#content').xheditor();
		$('#reset_button').click(function(){
			$('#content').val('');
		});
		
		function showDialog(url, options) {
			myDialog = art.dialog(options);// 初始化一个带有loading图标的空对话框
			$.post(url, options.param, function(data) {
				myDialog.content(data);
			});
		}
		$("#select_prize, #prizeList").click(function(){
			showDialog('cms/activity/select/page', {
				width : '380px',
				title : '选择参与本次活动的奖品',
				lock : true,
				param : { productIds : $("#productIds").val()}
			});
		});
		
		$("#add_form").validator({}, {
			callback:function(data){
				if (!$('#content').val()) {
					$('#contentError').html('内容不能为空!').addClass('frame_error');
					return false;
				} else {
					$('#contentError').html('').removeClass('frame_error');
				}
				 
				$("#add_form").ajaxSubmit(function(data){
					if (data.success == 'succeed') {
						to_page('/cms/activity/view/page');
					} else {
						art.dialog({icon: data.success,content: data.message,lock:true});
					}
				}); 
			}
		});
 	});
		
</script>